package day8;

/**
 * @author oldliu
 * @since 1.0
 */
public class Thread4 extends Thread {
    public Thread4(String n) {
        super(n);
    }

    //线程要执行的任务·
    @Override
    public void run() {
        for (int i = 1; i <= 50; i++) {
            System.out.println(getName() + " print :" + i);
            try {
                //释放获得的资源
                Thread.sleep(20);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        //至少5个线程（1主+4个子线程）
        //优先级不明显
        for (int i = 1; i <= 4; i++) {
            Thread4 th = new Thread4("线程" + i);
            th.start();
        }
    }
}
